<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创建class</title>
</head>
<body>
<script>
    class Animal{
        constructor(name,age,species,sex){
            this.name=name;
            this.age=age;
            this.species=species;
            this.sex=sex;
        }
        Eat(){
            console.log(this.name+"开饭啦，开饭啦！");
        }
        Sleep(){
            console.log(this.name+"数星星时间");
        }
    }
    class Erha extends Animal{
        constructor(name,age,species,sex){
            super(name,age,species,sex);
    }
        happy(){
            console.log("我是"+this.name+"今年"+this.age+"岁"+"现在要拆家啦，可快乐了");
        }
    }
    let erha=new Erha("二哈","2","犬类","雄性");
    erha.happy();
    erha.Eat();
    erha.Sleep();

</script>
</body>
</html>